import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

/* Layout */
import Layout from '@/layout'

/**
 * constantRoutes
 *没有权限要求的基本页面  
 *所有的角色都可以访问  
 */
export const constantRoutes = [{
        path: '/login',
        component: () =>
            import ('@/views/login/index'),
        hidden: true
    },
    {
        path: '/auth-redirect',
        component: () =>
            import ('@/views/login/auth-redirect'),
        hidden: true
    },
    {
        path: '/404',
        component: () =>
            import ('@/views/error-page/404'),
        hidden: true
    },
    {
        path: '/401',
        component: () =>
            import ('@/views/error-page/401'),
        hidden: true
    },
    {
        path: '/',
        component: Layout,
        redirect: '/system',
    },



    // {
    //     path: '/marketing',
    //     component: Layout,
    //     redirect: '/marketing/Index',
    //     alwaysShow: true, // will always show the root menu
    //     name: 'marketing',
    //     meta: {
    //         title: '学籍管理',
    //         icon: 'lock',
    //     },
    //     children: [{
    //         path: 'Index',
    //         component: () =>
    //             import ('views/marketing/index'),
    //         name: 'Index',
    //         meta: {
    //             title: '学籍',
    //         }
    //     }]
    // },
]

/**
 * asyncRoutes  
 *需要根据用户角色动态加载的路由  
 */
export const asyncRoutes = [{
        path: '/system',
        component: Layout,
        redirect: '/system/department',
        alwaysShow: true, // will always show the root menu
        name: 'system',
        meta: {
            title: '系统管理',
            icon: 'el-icon-setting',
            roles: ['admin']
        },
        children: [{
            path: 'department',
            name: 'department',
            component: () =>
                import ('views/department/DepartmentList'),
            meta: { title: '部门', icon: 'el-icon-s-grid', affix: false }
        }, {
            path: 'adminrole',
            name: 'adminrole',
            component: () =>
                import ('views/department/Role'),
            meta: { title: '角色（职位）', icon: 'el-icon-user', affix: false }
        }, {
            path: 'adminuser',
            name: 'adminuser',
            component: () =>
                import ('views/usermessage/AdminUserDiv'),
            meta: { title: '管理员', icon: 'el-icon-s-cooperation', affix: false }
        }, ]
    },

    {
        path: '/collegejw',
        component: Layout,
        redirect: '/collegejw',
        alwaysShow: true, // will always show the root menu
        name: 'collegejw',
        meta: {
            title: '学院管理(教务)',
            icon: 'el-icon-help',

            roles: ['admin', 'fdy', 'js']
        },
        children: [{
                path: 'teachingCycle',
                name: 'teachingCycle',
                component: () =>
                    import ('views/class/TeachingCycle'),
                meta: {
                    title: '教学周期',
                    roles: ['admin'],
                    affix: false
                }
            },
            //  {
            //     path: 'attendance',
            //     name: 'attendance',
            //     component: () =>
            //         import ('views/class/attendance'),
            //     meta: { title: '出勤率汇总', icon: 'dashboard', affix: false }
            // }, 
            // {
            //     path: 'jshour',
            //     name: 'jshour',
            //     component: () =>
            //         import ('views/class/jshour'),
            //     meta: { title: '讲师课时', icon: 'dashboard', affix: false }
            // },
            {
                path: 'classRoom',
                name: 'classRoom',
                component: () =>
                    import ('views/class/ClassRoom'),
                meta: {
                    title: '教室管理',
                    roles: ['admin'],
                    affix: false
                }
            }, {
                path: 'classList',
                name: 'classList',
                component: () =>
                    import ('views/class/classList'),
                meta: {
                    title: '班级管理',
                    roles: ['admin', 'fdy'],
                    affix: false
                }
            }, {
                path: 'students',
                name: 'students',
                component: () =>
                    import ('views/students/Students'),
                meta: {
                    title: '学生管理',
                    roles: ['admin', 'fdy'],
                    affix: false
                }
            }, {
                path: 'changeclass',
                name: 'changeclass',
                component: () =>
                    import ('views/students/changeclass'),
                meta: {
                    title: '学生调动',
                    roles: ['admin'],
                    affix: false
                }
            },
        ]
    },

    {
        path: '/collegexy',
        component: Layout,
        redirect: '/collegexy',
        alwaysShow: true, // will always show the root menu
        name: 'collegexy',
        meta: {
            title: '学院管理(学院',
            icon: 'el-icon-s-home',
            roles: ['admin'],
        },
        children: [{
                path: 'coursestage',
                name: 'coursestage',
                component: () =>
                    import ('views/class/coursestage'),
                meta: { title: '课程阶段', affix: false }
            }, {
                path: 'coursesystem',
                name: 'coursesystem',
                component: () =>
                    import ('views/class/coursesystem'),
                meta: { title: '课程体系', affix: false }
            },
            //  {
            //     path: 'adjustClassTime',
            //     name: 'adjustClassTime',
            //     component: () =>
            //         import ('views/class/AdjustClassTime'),
            //     meta: { title: '调课审核', icon: 'dashboard', affix: false }
            // }, {
            //     path: 'callRoll',
            //     name: 'callRoll',
            //     component: () =>
            //         import ('views/class/CallRoll'),
            //     meta: { title: '查课', icon: 'dashboard', affix: false }
            // },
            // {
            //     path: 'CallRolldetails/:id',
            //     name: 'CallRolldetails',
            //     component: () =>
            //         import ('views/class/CallRolldetails'),
            //     meta: { title: '查课信息', icon: 'dashboard', affix: false }
            // },
        ]
    },



    {
        path: '/studentScore',
        component: Layout,
        redirect: '/studentScore/Index',
        alwaysShow: true, // will always show the root menu
        name: 'studentScore',
        meta: {
            title: '综合积分管理',
            icon: 'el-icon-coin',
            roles: ['admin', 'fdy', 'dc', 'js'] // you can set roles in root nav
        },
        children: [

            {
                path: 'Edit',
                component: () =>
                    import ('views/students/StudentScore/Edit'),
                name: 'Edit',
                meta: {
                    title: '积分减分/加分',
                    roles: ['admin', 'fdy', 'dc', 'js']
                },

            },
            {
                path: 'Fdysub',
                component: () =>
                    import ('views/students/StudentScore/fdysub.vue'),
                name: 'Fdysub',
                meta: {
                    title: '扣分确认(导员)',
                    roles: ['admin', 'fdy']
                },

            },

            {
                path: 'Dcsub',
                component: () =>
                    import ('views/students/StudentScore/dcsub.vue'),
                name: 'Dcsub',
                meta: {
                    title: '扣分申诉(督察)',
                    roles: ['admin', 'dc']
                },

            },
            {
                path: 'Fdyawa',
                component: () =>
                    import ('views/students/StudentScore/fdyawa.vue'),
                name: 'Fdyawa',
                meta: {
                    title: '加分失败(导员)',
                    roles: ['admin', 'fdy']
                },

            },

            {
                path: 'Dcawa',
                component: () =>
                    import ('views/students/StudentScore/dcawa.vue'),
                name: 'Dcawa',
                meta: {
                    title: '加分确认(督察)',
                    roles: ['admin', 'dc']
                },

            },
            {
                path: 'Index',
                component: () =>
                    import ('views/students/StudentScore/index'),
                name: 'Index',
                meta: {
                    title: '综合积分制度',
                    roles: ['admin', 'fdy', 'dc', 'js']
                }
            },
            // {
            //     path: 'jsshow',
            //     component: () =>
            //         import ('views/students/StudentScore/jsshow'),
            //     name: 'jsshow',
            //     meta: {
            //         title: '讲师查看',
            //         roles: ['admin', 'js']
            //     },

            // },

        ]
    },

    {
        path: '/voice',
        component: Layout,
        redirect: '/voice/Index',
        alwaysShow: true, // will always show the root menu
        name: 'voice',
        meta: {
            title: '语音管理',
            icon: 'el-icon-phone-outline',
            roles: ['admin']
        },
        children: [
            // {
            //     path: 'Index',
            //     component: () =>
            //         import ('views/voice/voicesystem'),
            //     name: 'Index',
            //     meta: {
            //         title: '语音信息',
            //     }
            // },
            {
                path: 'luyin',
                component: () =>
                    import ('views/voice/luyin.vue'),
                name: 'luyin',
                meta: {
                    title: '语音',
                }
            },
            {
                path: 'message',
                component: () =>
                    import ('views/voice/Message.vue'),
                name: 'Message',
                meta: {
                    title: '上传语音',
                }
            },
            {
                path: 'jieduanbi',
                component: () =>
                    import ('views/voice/jieduanbi.vue'),
                name: 'Message',
                meta: {
                    title: '数据表格',
                }
            },

            {
                path: 'xueyuanbi',
                component: () =>
                    import ('views/voice/xueyuanbi.vue'),
                name: 'Message',
                meta: {
                    title: '可视化',
                }
            },

            {
                path: 'xueyuanbi2',
                component: () =>
                    import ('views/voice/xueyuanbi2.vue'),
                name: 'Message',
                meta: {
                    title: '可视化2',
                }
            }
        ]
    },


    // {
    //     path: '/punchcard',
    //     component: Layout,
    //     redirect: '/punchcard/index',
    //     alwaysShow: true, // will always show the root menu
    //     name: 'punchcard',
    //     meta: {
    //         title: '打卡功能管理',
    //         icon: 'el-icon-phone-outline',
    //         roles: ['admin']
    //     },
    //     children: [{
    //         path: 'index',
    //         component: () =>
    //             import ('views/department/punchcard.vue'),
    //         name: 'index',
    //         meta: {
    //             title: '教职工上班',
    //         }
    //     }, {
    //         path: 'attendancegl',
    //         component: () =>
    //             import ('views/department/attendanceshowgl.vue'),

    //         name: 'attendancegl',
    //         meta: {
    //             title: '出勤情况(管理)',
    //         }
    //     }, {
    //         path: 'attendancegr',
    //         component: () =>
    //             import ('views/department/attendanceshowgr.vue'),

    //         name: 'attendancegr',
    //         meta: {
    //             title: '出勤情况(个人)',
    //         }
    //     },{
    //         path: 'Index',
    //         component: () =>
    //             import ('views/marketing/index'),
    //         name: 'Index',
    //         meta: {
    //             title: '学籍',
    //         }
    //     }]
    // },





    // {
    //     path: '/family-school',
    //     component: Layout,
    //     redirect: '/family-school/index',
    //     alwaysShow: true, // will always show the root menu
    //     name: 'family-school',
    //     meta: {
    //         title: '家校互通',
    //         icon: 'el-icon-s-home',
    //     },
    //     children: [{
    //         path: 'index',
    //         component: () =>
    //             import ('views/family-school/index'),
    //         name: 'index',
    //         meta: {
    //             title: '家校互通',
    //         }
    //     }, ]
    // },
    // {
    //     path: '/transmit',
    //     component: Layout,
    //     redirect: '/transmit/index',
    //     alwaysShow: true, // will always show the root menu
    //     name: 'transmit',
    //     meta: {
    //         title: '利好传递',
    //         icon: 'el-icon-s-ticket',
    //     },
    //     children: [{
    //         path: 'index',
    //         component: () =>
    //             import ('views/transmit/index'),
    //         name: 'index',
    //         meta: {
    //             title: '利好传递',
    //         }
    //     }, ]
    // },
]




const createRouter = () => new VueRouter({
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router